/*************************************************************************
	> File Name: FlyWeight.h
	> Author: Joker
	> Mail: mahongtao@foxmail.com 
	> Created Time: 2020-09-22 13:48:42
 ************************************************************************/

#ifndef __FLYWEIGHT_H__
#define __FLYWEIGHT_H__

#include <string>
#include <list>

using std::string;
using std::list;

typedef string STATE;

class FlyWeight
{
public:
    virtual ~FlyWeight();

    STATE GetIntrinsicState();
    virtual void Operation(STATE & ExtrinsicState) = 0;
protected:
    FlyWeight(const STATE & state);

private:
    STATE _State;
};

class FlyWeightFactory
{
public:
    FlyWeightFactory();
    ~FlyWeightFactory();

    FlyWeight * GetFlyWeight(const STATE & key);

private:
    list<FlyWeight *> _listFlyWeight;
};

class ConcreateFlyWeight
:public FlyWeight
{
public:
    ConcreateFlyWeight(const STATE & state);
    virtual ~ConcreateFlyWeight();

    virtual void Operation(STATE & ExtrinsicState);
};

#endif
